<template>
    <div id="docx"></div>
</template>

<script>
import jsPreviewDocx from "@js-preview/docx";
import '@js-preview/docx/lib/index.css'
export default {
    name: "JsPreviewDocxDemo",
    data() {
        return {
            myDocxPreviewer: null
        }
    },
    mounted() {
        //初始化时指明要挂载的父元素Dom节点
        this.myDocxPreviewer = jsPreviewDocx.init(document.getElementById('docx'));

        //传递要预览的文件地址即可
        this.myDocxPreviewer.preview('/api/api/v1/download-shared-object/aHR0cDovLzEyNy4wLjAuMTo5MDAwL3Nlbmlvci12YWx2ZS1odWIvdHV0b3JpYWxzLyVFNyU5MyVBMyVFOCU4NiU5QyVFNyU5NyU4NSVFNiVCNSU4QiVFOCVBRiU5NS5kb2N4P1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9NEcyS0RCS1RJSkpSVjFOVFUyTEclMkYyMDI1MDUyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA1MjNUMTAzOTEzWiZYLUFtei1FeHBpcmVzPTQzMjAwJlgtQW16LVNlY3VyaXR5LVRva2VuPWV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoWTJObGMzTkxaWGtpT2lJMFJ6SkxSRUpMVkVsS1NsSldNVTVVVlRKTVJ5SXNJbVY0Y0NJNk1UYzBPREF6TmpBeU1Td2ljR0Z5Wlc1MElqb2liV2x1YVc5aFpHMXBiaUo5LjNsR251TVNLT0xkNF9Tdk10aVBxSDhtM3pXTDdTM3lqS2pFTHIwUHJXUHotSl9nTVRQTVdqdkp5WURsd3g5LWkxUWdlelV6S19ULXhMRnIzMWZKSUtBJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ2ZXJzaW9uSWQ9bnVsbCZYLUFtei1TaWduYXR1cmU9MzJmODgyMGIzMTkxYTBmZmYwNjYxMWM3YTE2MTJiMjJmZTI3YTM1ZTIxOTQyZjY2ZjEwMGE2MGYxMTAyMTg5Ng').then(() => {
            console.log('预览完成');
        }).catch(e => {
            console.log('预览失败', e);
        })
    },
    beforeDestroy() {
        this.myDocxPreviewer.destroy();
    }
};
</script>

<style scoped></style>